#include <iostream>
#include <vector>
#include <cmath>
#include <string>

bool isPrime(int x) {
    for (int y = 2; y <= sqrt(x); ++y) {
        if (x % y == 0) {
            return false;
        }
    }
    return true;
}

int main() {
    std::string input;
    std::vector<std::string> t{"zero", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine"};
    int rez = 0;
    int d = 100;

    std::vector<std::string> s;
    std::string word;

    while (std::cin >> word) {
        s.push_back(word);
    }

    bool flag = (s.size() == 3);
    int delta = 1;

    for (const auto& x : s) {
        for (size_t i = 0; i < t.size(); ++i) {
            if (x == t[i]) {
                rez += i * d;
                d = d / 10;
                break;
            }
        }
    }

    while (flag) {
        if (isPrime(rez - delta)) {
            std::cout << rez - delta << std::endl;
            break;
        }
        if (isPrime(rez + delta)) {
            std::cout << rez + delta << std::endl;
            break;
        }
        delta++;
    }

    if (!flag) {
        std::cout << "wrong input" << std::endl;
    }

    return 0;
}